/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * AspectMethodBodyGUI.java
 *
 * Created on 1 Apr, 2010, 12:08:53 PM
 */
package jaspect;

/**
 *
 * @author Arjun
 */
public class AspectMethodBodyGUI extends javax.swing.JDialog {

    private String methodName;
    private String argumentList;
    AspectMethodGUI am;

    /** Creates new form AspectMethodBodyGUI
     * @param parent
     * @param modal
     * @param am
     */
    public AspectMethodBodyGUI(java.awt.Frame parent, AspectMethodGUI am, boolean modal) {
        super(parent, modal);
        this.am = am;
        initComponents();


    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        editorJava = new javax.swing.JEditorPane();
        jToolBar1 = new javax.swing.JToolBar();
        buttonSave = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setAlwaysOnTop(true);
        setResizable(false);

        jScrollPane1.setPreferredSize(new java.awt.Dimension(490, 430));
        jScrollPane1.setVerifyInputWhenFocusTarget(false);

        editorJava.setMinimumSize(new java.awt.Dimension(700, 20));
        editorJava.setPreferredSize(new java.awt.Dimension(800, 400));
        jScrollPane1.setViewportView(editorJava);

        getContentPane().add(jScrollPane1, java.awt.BorderLayout.CENTER);

        jToolBar1.setRollover(true);
        jToolBar1.setPreferredSize(new java.awt.Dimension(440, 23));

        buttonSave.setText("Save");
        buttonSave.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonSaveActionPerformed(evt);
            }
        });
        jToolBar1.add(buttonSave);

        getContentPane().add(jToolBar1, java.awt.BorderLayout.PAGE_END);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void buttonSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonSaveActionPerformed
        // TODO add your handling code here:
        am.getTd().setMethodBody(editorJava.getText());
        this.setVisible(false);
    }//GEN-LAST:event_buttonSaveActionPerformed

    /**
     * This method makes the method prototype
     */
    public void setInit() {
        StringBuilder sb = new StringBuilder();
        sb.append("public ");
        sb.append(getMethodName());
        sb.append(" (");
        sb.append(getArgumentList());
        sb.append(" )  {\n}");
        editorJava.setText(sb.toString());


    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton buttonSave;
    private javax.swing.JEditorPane editorJava;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JToolBar jToolBar1;
    // End of variables declaration//GEN-END:variables

    /**
     * @return the methodName
     */
    public String getMethodName() {
        return methodName;
    }

    /**
     * @param methodName the methodName to set
     */
    public void setMethodName(String methodName) {
        this.methodName = methodName;
    }

    /**
     * @return the argumentList
     */
    public String getArgumentList() {
        return argumentList;
    }

    /**
     * @param argumentList the argumentList to set
     */
    public void setArgumentList(String argumentList) {
        this.argumentList = argumentList;
    }
}
